package qldc.pm.tiensu.util;

import com.liferay.portal.kernel.util.Validator;

import qldc.pm.qtht.dmdc.utils.DiaChiUtils;
import qldc.pm.qtht.model.NguoiDung;
import qldc.pm.qtht.service.NguoiDungLocalServiceUtil;
import qldc.pm.tiensu.dto.YeuCauTrichLucDTO;
import qldc.pm.tiensu.model.KetQuaTrichLuc;
import qldc.pm.tiensu.model.YeuCauTrichLuc;
import qldc.pm.tiensu.service.KetQuaTrichLucLocalServiceUtil;

public class Converters {
	public static YeuCauTrichLucDTO convertFormEntityToDto_YeuCauTrichLuc(YeuCauTrichLuc yeucau){
		YeuCauTrichLucDTO result = new YeuCauTrichLucDTO();
		result.setCoQuanYeuCauTrichLuc(yeucau.getCoQuanYeuCauTrichLuc());
		result.setHoVaTenDoiTuongCanTrichLuc(yeucau.getHoVaTenDoiTuongTrichLuc());
		result.setMaYeuCauTrichLuc(yeucau.getMaYeuCauTrichLuc());
		result.setNgayLapYeuCauTrichLuc(yeucau.getNgayLapTrichLuc());
		result.setNgaySinhDoiTuongCanTrichLuc(yeucau.getNgaySinhDoiTuongTrichLuc());
		result.setNgayYeuCauTraTrichLuc(yeucau.getNgayDeNghiTraTrichLuc());
		result.setNguoiYeuCauTrichLuc(yeucau.getHoVaTenNguoiYeuCauTrichLuc());
		result.setTrangThaiHoSo(yeucau.getDaTrichLuc());
		result.setYeuCauTrichLucId(yeucau.getYeuCauTrichLucId());
		NguoiDung nguoiDung = NguoiDungLocalServiceUtil.findByNguoiDungId(yeucau.getUserId());
		if (Validator.isNotNull(nguoiDung))
			result.setCanBoLapYeuCauTrichLuc(nguoiDung.getHoVaTen());
		KetQuaTrichLuc kq = KetQuaTrichLucLocalServiceUtil.findByYeuCauTrichLucId(yeucau.getYeuCauTrichLucId());
		String diaChi = DiaChiUtils.createBlockDiaChi(yeucau.getNoiThuongTruDoiTuongTrichLucTinhId(), yeucau.getNoiThuongTruDoiTuongTrichLucQuanHuyenId(), yeucau.getNoiThuongTruDoiTuongTrichLucPhuongXaId(),"");
		result.setDiaChi(diaChi);
		result.setKetQuaTrichLuc(-1);
		if (Validator.isNotNull(kq)){
			result.setKetQuaTrichLuc(kq.getKetQua());
			result.setNgayTrichLuc(kq.getNgayTraCuu());
			result.setNguoiTraCuuHoSo(kq.getNguoiTraCuuHoSo());
		}
		return result;
		
		
		 
	}
}
